package SortExe;

import java.util.Arrays;

public class EvenTimesNum {

    public static int evenTimesNum1(int[] arr){
        int eor = 0;
        for (int e:arr){
            eor = eor^e;
        }
        return eor;
    }

    public static int[] evenTimesNum2(int[] arr){
        int eor1 = 0;
        for (int e:arr){
            eor1 = eor1 ^ e;
        }
        int rightOne = eor1 & (~eor1 +1);
        int eor = 0;
        for (int e:arr){
            if ((e&rightOne) == 0){
                eor = eor ^ e;
            }
        }
        eor1 = eor1 ^eor;
        int[] array = {eor1,eor};
        return array;
    }
    public static void main(String[] args) {
        int[] arr = {1,1,1,5,5,6,4,7,7,5,4,6};
        int[] array = evenTimesNum2(arr);
        System.out.println(Arrays.toString(array));
    }
}
